package top.hidoctor.auscultation.adapter;

import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tang.net.NetClient;

import java.util.List;

import top.hidoctor.auscultation.R;
import top.hidoctor.auscultation.bean.UserBean;
import top.hidoctor.auscultation.widget.GlideCircleTransform;

public class RenyuanAdapter extends BaseQuickAdapter<UserBean.ResultBean> {
    public RenyuanAdapter(int layoutResId, List<UserBean.ResultBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, UserBean.ResultBean item) {
        helper.setText(R.id.tv_name, item.getRealName())
                .setText(R.id.tv_zhicheng, item.getRole().getName())
                .setText(R.id.tv_phone, item.getPhone())
                .setText(R.id.tv_hospital, item.getHospital().getHospitalName())
                .setBackgroundRes(R.id.ll_content, item.isCheck() ? R.drawable.bg_gray_8_2 : R.drawable.bg_white_8);
        RequestOptions optionsCircle = new RequestOptions();
        DrawableTransitionOptions transitionOptions = new DrawableTransitionOptions();
        Glide.with(mContext)
                .load(NetClient.IMG_URL + item.getAvatar())
                .apply(optionsCircle.transform(new GlideCircleTransform()).placeholder(R.drawable.ic_avater_zw))
                .transition(transitionOptions.crossFade())
                .into((ImageView) helper.getView(R.id.iv_avater));
    }
}
